Fixing two double-escaping problems in Linker::link (Xml::element escapes the element...
authorRotem Liss <rotem@users.mediawiki.org>
Fri, 1 Aug 2008 10:15:29 +0000 (10:15 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Fri, 1 Aug 2008 10:15:29 +0000 (10:15 +0000)
* In Linker::userLink - already live in Wikimedia sites.
* When no text is given, i.e. in Linker::linkText.
Also fixing documentation comment to prevent more mistakes.

includes/Linker.php

index 852ea80..278e974 100644 (file)
@@ -146,7 +146,7 @@ class Linker {
         * @param $target        Title  Can currently only be a Title, but this may
         *   change to support Images, literal URLs, etc.
         * @param $text          string The HTML contents of the <a> element, i.e.,
-        *   the link text.  This is raw HTML and will not be escaped.  If null,
+        *   the link text.  This will be escaped.  If null,
         *   defaults to the prefixed text of the Title; or if the Title is just a
         *   fragment, the contents of the fragment.
         * @param $query         array  The query string to append to the URL
@@ -287,9 +287,9 @@ class Linker {
                # If the target is just a fragment, with no title, we return the frag-
                # ment text.  Otherwise, we return the title text itself.
                if( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) {
-                       return htmlspecialchars( $target->getFragment() );
+                       return $target->getFragment();
                }
-               return htmlspecialchars( $target->getPrefixedText() );
+               return $target->getPrefixedText();
        }
 
        /**
@@ -1039,13 +1039,12 @@ class Linker {
         * @private
         */
        function userLink( $userId, $userText ) {
-               $encName = htmlspecialchars( $userText );
                if( $userId == 0 ) {
                        $page = SpecialPage::getTitleFor( 'Contributions', $userText );
                } else {
                        $page = Title::makeTitle( NS_USER, $userText );
                }
-               return $this->link( $page, $encName );
+               return $this->link( $page, $userText );
        }
 
        /**